package com.xbb.controller.sys;

import com.xbb.common.RespResult;
import com.xbb.entity.Question;
import com.xbb.mapper.QuestionMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/sys/question")
public class SysQuestionController {

    @Resource
    private QuestionMapper questionMapper;

    // 问卷题目管理

    // 添加
    @ResponseBody
    @RequestMapping("/add")
    public RespResult add(@RequestBody Question question) {
        questionMapper.insertSelective(question);
        return new RespResult();
    }

    // 编辑
    @ResponseBody
    @RequestMapping("/edit")
    public RespResult edit(@RequestBody Question question) {
        questionMapper.updateByPrimaryKeySelective(question);
        return new RespResult();
    }

    // 删除
    @ResponseBody
    @RequestMapping("/delete")
    public RespResult delete(@RequestBody Integer id) {
        questionMapper.deleteByPrimaryKey(id);
        return new RespResult();
    }

}
